package 常用API.Calendar;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Calendar;
import java.util.Date;

//日历
public class CalendarDemo {
    public static void main(String[] args) {
        //创建日历对象的实例
        Calendar calendar = Calendar.getInstance();
        System.out.println("Calendar.getInstance : " + calendar);
        System.out.println();

        //Calendar 转为 Date对象
        Date date = calendar.getTime();
        System.out.println("calendar.getTime : "+date);

        System.out.println("------------------------");
        //Calendar 获取 年月日
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH);
        int dayMonth = calendar.get(Calendar.DAY_OF_MONTH);
        int dayWeek = calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH);
        System.out.println(year+"年"+month+"月"+dayMonth+"日 "+"星期"+dayWeek);

        //设置 年月日
        calendar.set(2020,7,22);
        System.out.println(calendar.get(Calendar.YEAR));
    }
}
